import api from "@/api/apiConfig";
import ajax from "@/api/http";
import wx from "weixin-jsapi";
export function getWxAuth(fullpath, system) {
  let url = "";
  if (system === "ios") {
    url = encodeURIComponent(window.entryUrl.split("#")[0]);
  } else {
    url = encodeURIComponent(`http://gift.hrycf.com${fullpath}`.split("#")[0]);
  }
  if (fullpath === "/home") {
    ajax.post(api.getWx, { url: url }).then(res => {
      wx.config({
        debug: false,
        appId: res.appId, // 必填，公众号的唯一标识
        timestamp: res.timestamp, // 必填，生成签名的时间戳
        nonceStr: res.nonceStr, // 必填，生成签名的随机串
        signature: res.signature, // 必填，签名，见附录1
        jsApiList: [
          "hideAllNonBaseMenuItem",
          "showMenuItems",
          "onMenuShareTimeline",
          "onMenuShareAppMessage"
        ] // 必填，需要使用的 JS 接口列表，所有JS接口列表见附录2
      });
    });
  }
}
